/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package util.archivo;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
/**
 *
 * @author Administrador
 */
public class Ejecutar {
    private static Process proceso;

    public static void ejecutarArchivo(String programa, String ruta) {
        String error = "";
        String salida = "";

        try {
            proceso = Runtime.getRuntime().exec("cmd.exe /C " + programa + " " + ruta + "");
            BufferedReader brStdErr;
            try (BufferedReader brStdOut = new BufferedReader(new InputStreamReader(proceso.getInputStream()))) {
                brStdErr = new BufferedReader(new InputStreamReader(proceso.getErrorStream()));
                String str;
                while ((str = brStdOut.readLine()) != null) {
                    salida = salida + str + "\n";
                }
                while ((str = brStdErr.readLine()) != null) {
                    error = error + str + "\n";
                }
            }
            brStdErr.close();
            proceso.destroy();
        } catch (Exception e) {
        }
    }
}
